﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace HungryCrowdLibrary.Data
{
    internal class TraderData
    {
        internal List<Trader> GetList(Expression<Func<Trader, bool>> search)
        { 
            var traders = new List<Trader>();

            using(var hctx = new HungryCrowdEntities())
            {
                traders = hctx.Traders.Where(search).ToList();
            }

            return traders;
        }

        internal Trader GetDetail(Expression<Func<Trader, bool>> search)
        {
            var vendor = new Trader();

            using (var hctx = new HungryCrowdEntities())
            {
                vendor = hctx.Traders.Where(search).SingleOrDefault();
            }

            return vendor;
        }        
    }
}
